package com.engineering.elink.dao;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import com.engineering.elink.co.BaseCo;
import com.engineering.elink.co.BlogCo;
import com.engineering.elink.domain.Blog;

public interface BlogMapper {
    int deleteByPrimaryKey(String blogId);

    int insert(Blog record);

    int insertSelective(Blog record);

    Blog selectByPrimaryKey(String blogId);

    int updateByPrimaryKeySelective(Blog record);

    int updateByPrimaryKey(Blog record);
    
	List<Blog> selectList(@Param("co")BlogCo co,@Param("userId")String userId);

	int selectCount(@Param("co")BlogCo co,@Param("userId")String userId);
	
	List<Blog> selectBlogListByUserId(@Param("co")BaseCo co,@Param("userId")String userId,@Param("type") String type);
	
	int selectBlogListCountByUserId(@Param("co")BaseCo co,@Param("userId")String userId,@Param("type") String type);

	Blog getInfo(@Param("blogId")String blogId,@Param("userId")String userId,@Param("type") int type);
	
	Blog getInfoByUserId(@Param("blogId")String blogId,@Param("userId")String userId,@Param("type") int type);

	List<Blog> getGreetBlog(@Param("count") int count);

	Blog selectPre(@Param("createTime")Date createTime,@Param("type") int type,@Param("userId")String userId);

	Blog selectNext(@Param("createTime")Date createTime,@Param("type") int type,@Param("userId")String userId);

	List<Blog> selecOtherBlogtList(@Param("co")BaseCo co, @Param("userId")String userId, @Param("blogId")String blogId,@Param("type") String type);

	int selectOtherBlogCount(@Param("userId")String userId,@Param("blogId") String blogId,@Param("type") String type);
	
	List<Blog> selecOtherBlogtListByUserId(@Param("co")BaseCo co, @Param("userId")String userId, @Param("blogId")String blogId,@Param("type") String type);

	int selectOtherBlogCountByUserId(@Param("userId")String userId,@Param("blogId") String blogId,@Param("type") String type);
	
	@Update("update  blog set type = 2  where FIND_IN_SET(blog_id,#{blogIds}) and user_id = #{userId}")
	int updateStationWorks(@Param("blogIds")String blogIds, @Param("userId")String userId);
	
	@Update("update  blog set type = 0  where FIND_IN_SET(blog_id,#{blogIds}) and user_id = #{userId}")
	int delStationWorks(@Param("blogIds")String blogIds, @Param("userId")String userId);
	
}